import { createBrowserRouter} from "react-router-dom";
import { lazy } from "react";













const route = [
  {
    path: "/",
    Component: lazy(()=>import("@/pages/Layout/main")),
    loader:()=>{
      console.log('loading home')
    },
    children:[
      {path:"/",Component:lazy(()=>import("@/pages/Home"))},
      {path:"login",Component:lazy(()=>import("@/pages/Login"))},
      {path:"register",Component:lazy(()=>import("@/pages/register"))},
      { path:"manage",
        Component:lazy(()=>import("@/pages/Layout/manage")),
        children:[
          {path:"list",Component:lazy(()=>import("@/pages/Manage/list"))},
          {path:"star",Component:lazy(()=>import("@/pages/Manage/star"))},
          {path:"trash",Component:lazy(()=>import("@/pages/NotFound"))}
        ]
      },
      {path:"*",Component:lazy(()=>import("@/pages/Layout/main"))}
    ]
  },
  {
        path:"question",
        Component:lazy(()=>import("@/pages/Layout/question")),
        children:[
          {path:"edit/:id",Component:lazy(()=>import("@/pages/Question/edit"))},
          {path:"stat/:id",Component:lazy(()=>import("@/pages/Question/stat"))}
        ]
  }
]



const router = createBrowserRouter(route)


//react-router-dom前置路由守卫




export default router;


//常用的路由常量
export const HOME_PATH = "/"